// ****************************************************************
// Copyright 2012, Stephan Burguchev
// e-mail: me@sburg.net
// ****************************************************************
// *
using System;
using System.IO;
using System.Security.Cryptography;

namespace Updater.Common
{
    public static class ChecksumHelper
    {
        public static byte[] ComputeFileChecksum(string filename, ChecksumType checksumType)
        {
            switch (checksumType)
            {
            case ChecksumType.Sha1:
                using (FileStream stream = File.OpenRead(filename))
                {
                    return SHA1.Create().ComputeHash(stream);
                }

            case ChecksumType.Sha256:
                using (FileStream stream = File.OpenRead(filename))
                {
                    return SHA256.Create().ComputeHash(stream);
                }

            default:
                throw new ArgumentOutOfRangeException("checksumType");
            }
        }
    }
}
